package com.ithuameng.admin.app.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ithuameng.admin.app.system.dao.SysJobLogMapper;
import com.ithuameng.admin.app.system.model.SysJobLog;
import com.ithuameng.admin.app.system.service.ISysJobLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * SysJobLog service implementation
 *
 * @author ithaumeng
 */
@Slf4j
@Transactional
@Service
public class SysJobLogServiceImpl extends ServiceImpl<SysJobLogMapper, SysJobLog> implements ISysJobLogService {

    @Override
    public List<SysJobLog> getJobLogByJobId(String jobId) {
        QueryWrapper<SysJobLog> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(SysJobLog.JOB_ID, jobId);
        queryWrapper.select(SysJobLog.EXECUTE_TIME, SysJobLog.END_TIME, SysJobLog.PARAMETER, SysJobLog.STATUS);
        queryWrapper.orderByDesc(SysJobLog.EXECUTE_TIME);
        queryWrapper.last("limit 100");
        return super.list(queryWrapper);
    }
}
